package org.jeecg.modules.demo.yhs.Controller;

import org.jeecg.modules.demo.yhs.POJO.History;
import org.jeecg.modules.demo.yhs.POJO.Result;
import org.jeecg.modules.demo.yhs.POJO.Shistory;
import org.jeecg.modules.demo.yhs.Service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Y")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @GetMapping(value = "/history",produces = "application/json; charset=utf-8")
    public Result history(){
        List<History> list=historyService.findAll();
        if(list!=null)
         return new Result(200,"已查到数据",list);
        else
            return new Result(300,"未找到数据");
    }


    @RequestMapping("/insert")
    public Result insert(@PathVariable Shistory shistory){
        System.out.println(shistory.toString());
        int a=historyService.insert(shistory);
       if(a>0)
           return new Result(200,"成功");
       else
           return new Result(300,"失败");
    }

}
